package com.michaelwolf.mytool.wcfcompmanger.wcfanalyzer;

import java.util.Map;

import org.w3c.dom.Node;

import com.michaelwolf.mytool.wcfcompmanger.wcfanalyzer.WCFLoader.TraverseCacheData;

public class ComponentIDAttributeHandler implements AttributesHandler {

	@Override
	public void process(Node attrnode, TraverseCacheData traverseCacheData, String moduleName) {
		Map<String, Node> ComponentIdMap = traverseCacheData.getComponentIdMap();
		
		Node compNode = NodeHandler.getOwnerCompNode(attrnode);
		if(compNode==null)
			return;
		
		String referID;
		if(compNode.getNodeName().equals("type-mapping")){
			referID = "type-mapping"+"." + compNode.getAttributes().getNamedItem("data-type").getNodeValue();
		}else if(compNode.getNodeName().equals("icon")){
			referID = "icon-"+ "system:" +moduleName+"." + compNode.getAttributes().getNamedItem("id").getNodeValue();
		}else{
			referID = "system:" +moduleName+"." + compNode.getAttributes().getNamedItem("id").getNodeValue();
		}
		
		ComponentIdMap.put(referID, compNode);

	}

}
